home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
logicsim.arc
/
LOGICSIM.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1986-01-08
|
5KB
|
117 lines
{------------------------------------------------------------------------}
{ Logic Simulation program }
{ Original Basic version by }
{ Robert M. McDermott; }
{ Pascal program by: Greg C. Miner April 1985 }
{------------------------------------------------------------------------}
PROGRAM Logic_Simulator;
Const
SCREEN = 22; LINE = 80;
MNAMS = 600; MLGIC = 600;
MTYPES = 200; MEXTERN = 100;
MSAMPLES = SCREEN; L0 = 0;
L1 = 3; LX = 1;
Var
Filvar,Device: Text;
Filename: String[10]; {source file input var}
Ok: Boolean;
Ls,ASK,Xs,XXs,Header: String[80];
NAMES: Array[0..MNAMS] of String[8]; {Signal Names }
TEX: Array[0..1] of String[1]; { }
TYPES: Array[0..MTYPES] of String[8]; {Logic Types }
TYPEX: Array[0..MTYPES] of Integer; {Pointers to logic desc}
LIs: Array[0..10] of String[8]; {Temporary }
LOGIN: Array[0..3] of String[8]; {Logic Input Symbol }
LOGPR: Array[0..3] of String[8]; {Logic Print Symbol }
LNOT: Array[0..3] of Integer; {Logic Inversion }
LV: Array[0..3] of Integer; { }
LO: Array[0..MLGIC,0..8] of Integer; {Logic Description }
EX: Array[0..MEXTERN,0..10] of Integer; {External Stimuli }
OLD: Array[0..MNAMS] of Integer; {Old logic value array }
SAMPLED:Array[0..MSAMPLES] of Integer; {Sampled Nodes }
T: Array[0..10] of Integer; {Temporary }
INPUT: Array[0..10] of Integer;
XC,XD,XM,D0,D1,YE,DL,
Q0,Q1,Y0,Y1,YC,YL,XSS,XR,XL,
XQ,C9,XO,PX,PY,PC,L,LT,
MX,NLGIC,NTYPE,NPRIM,I,I1,I2,II,J,LI,
FOUND,TPTR,SLGIC,NNAM,ERROR,MM,LOx,T1,TIME,
INCREMENT,X,X1,TL,STF,Y,M1,K,K1,FM,
XX,NE,NSAMPLED,E0,E1,E2,E3,E9,RI: Integer;
NEW: Array[0..MLGIC] of Integer;
ME: Array[0..MLGIC,0..1] of Integer;
S0: Array[0..400] of Integer;
S1: Array[0..400] of Integer;
S2: Array[0..400] of Integer;
{$ILogicsim.inc}
Begin (*............. MAIN .............*)
ClrScr;
Writeln('{----------------------------------------------------------------}');
Writeln('{ Logic Simulation program }');
Writeln('{ Original Basic version by }');
Writeln('{ Robert M. McDermott; }');
Writeln('{ Pascal program by: Greg C. Miner April 1985 }');
Writeln('{ }');
Writeln('{ For information and operational description see }');
Writeln('{ "The Design of an Advanced Logic Simulator" }');
Writeln('{ BYTE Magazine, April 1983 }');
Writeln('{----------------------------------------------------------------}');
Writeln;
Writeln(' ',MNAMS,' Names, ',MLGIC,' Logic Devices,');
Writeln(' ',MTYPES,' Types, ',MEXTERN,' External Stimuli');
Repeat
Writeln; Writeln;
Write(' Source file name: ');
Read(Filename); writeln; writeln;
I:=pos(filename,':');
if I=0 then Filename:=Filename+'.LGC';
Assign(Filvar,Filename);
{$I-} reset(Filvar); {$I+}
Ok:=(IOresult=0);
if not Ok then Writeln('File: ',Filename,'.LGC not found.');
until Ok;
Writeln;
Write('Output Expansion to ''P''rinter, ''F''ile ? ');
Readln(ASK); Ask:=Ask+' ';
Ask:=upcase(copy(Ask,1,1));
Assign(Device,'CON:');
if Ask='P' then Assign(Device,'LST:');
if Ask='F' then Assign(Device,copy(filename,1,length(filename)-3)+'LST');
ClrScr;
Rewrite(Device);
Writeln(Device,'Logic Simulator: ',Filename);
Writeln(Device);
Writeln('***** Initializing Arrays');
Initialize;
Writeln('***** Reading in any Macros');
ReadMacros;
Writeln('***** Reading in Logic Network');
Header:='Logic Network';
WriteHeader;
ReadInLogicDescription;
Writeln('***** Expanding any Macros');
ExpandMacros;
ListExpansion;
Writeln('***** Reading in External Stimuli');
ReadExternals;
Writeln('***** Checking for Errors');
CheckErrors;
Writeln('***** Reading in Nodes to be Sampled');
ReadNodes;
Writeln('***** Setting up for Simulation');
SetUpSimulation;
Close(Device);
END.